<?php
// @formatter:off
/**
 * @file WCGContainer.php
 * @author Alejandro Dario Simi
 * @date $Date: 2013-07-11 21:02:48 +0000 (Thu, 11 Jul 2013) $
 *
 * $Id: WCGContainer.php 95 2013-07-11 21:02:48Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/branches/wcomix-1.0/includes/containers/WCGContainer.php $
 */
// @formatter:on

/**
 * @class WCGContainer
 * This class represents a container for objects managed by certain
 * WCGHolder. It logic allows to access this objects in many way, like by id,
 * by name and others.
 */
class WCGContainer extends WCContainer {
	/**
	 * @var WCGroup Since this container depends on groups, this will be the
	 * pointer to the group in which depend. Every element held by this
	 * container will belong to this group.
	 */
	protected $_group = false;
	/**
	 * Specific constructor of this class.
	 *
	 * @param WCGHolder $holder This will be the element's holder to be used
	 * on those items with delayed loading.
	 * @param WCGroup $group This is the group to use when loading elements.
	 * @param boolean $invalids This parameter activates the loading of
	 * elements with issues.
	 */
	public function __construct(WCGHolder &$holder, WCGroup &$group, $invalids = false) {
		//
		// Calling the basic constructor.
		parent::basicConstructor($holder, $invalids);
		//
		// Saving the group pointer.
		$this->_group = $group;
	}
	/**
	 * Specific destructor of this class.
	 */
	public function __destruct() {
		//
		// Calling the basic destructor.
		parent::basicDestructor();
	}
	//
	// Protected methods.
	/**
	 * This method asks to the element's holder for certain element based on
	 * its id and group.
	 *
	 * @param int $id ID of the element to requested.
	 */
	protected function loadItemFromHolder($id) {
		//
		// Asking for the element based on its id and group.
		return $this->_holder->item($id, $this->_group);
	}
}
?>